//
//  ActiviteVerificationVC.m
//  KuWoCan
//
//  Created by hwd on 17/3/15.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "ActiviteVerificationVC.h"
#import "ProsecutorCell.h"
#import "DoubleLabCell.h"
#import "PhotoManageCell.h"
#import "BottomDoubleBtnView.h"
#import "VerificationApplyVC.h"

@interface ActiviteVerificationVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,copy) NSArray *constArr;

@end


@implementation ActiviteVerificationVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSArray *constStrArr = @[@"活动名称",@"活动目的",@"产品清单",@"执行城市",@"执行范围",@"执行时间",@"内容及形式",@"物料",@"费用",@"费效比率",@"支持/配合部门",@"销售额",@"提报人",@"提报省区",@"经销商"];
    _constArr = constStrArr;
    
    NSArray *paraStrArr = @[@"通路奖励",@"推动渠道,提升认知",@"1000箱200ML 营养多 原味",@"长沙",@"经销商",@"4.1-4.30",@"给予15%的费用支持",@"费用: 200ML 营养多",@"9800",@"15.83%",@"销管部",@"8000",@"张志敏",@"湖南",@"长沙北大仓"];
    _paraArr = paraStrArr;
    
    
    [self setUpUI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)changeInfo
{
    VerificationApplyVC *vc = [[VerificationApplyVC alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)setUpUI
{
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"核销详情";
    
    [self createRightButton:@"修改" selector:@selector(changeInfo)];
    
    //创建列表
    UITableView *tabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStyleGrouped];
    tabView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tabView.estimatedRowHeight = 40.0;
    tabView.rowHeight = UITableViewAutomaticDimension;
    tabView.delegate = self;
    tabView.dataSource = self;
    [self.view addSubview:tabView];
    [tabView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@0);
        make.left.right.equalTo(@0);
        make.bottom.equalTo(@-75);
    }];
    
    BottomDoubleBtnView *bottomView = [[BottomDoubleBtnView alloc] init];
    [self.view addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(@0);
        make.height.equalTo(@75);
    }];
    
}


//开始下单
- (void)startPlaceAnOrder
{
    //    OrderCargoChooseVC *vc =[[OrderCargoChooseVC alloc] init];
    //    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark tableViewDelegate,DataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0)
    {
        return 1;
    }
    else if (section == 1)
    {
        return _constArr.count;
    }
    else
    {
        return 1;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0 || section == 1)
    {
        return 50;
    }
    else
    {
        return 20;
    }
}


- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 0)
    {
        UIView *headView = [UIView new];
        headView.backgroundColor = [UIColor whiteColor];
        UILabel *lab = [UILabel new];
        lab.text = @"审批信息";
        lab.textColor = [UIColor blackColor];
        lab.font = KwFont(15);
        [headView addSubview:lab];
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(headView.mas_left).offset(20);
            make.top.equalTo(headView.mas_top).offset(15);
            make.height.equalTo(@15);
        }];
        
        UIView *lineView = [UIView new];
        lineView.frame = CGRectMake(0, 46, self.view.bounds.size.width, 1.5);
        lineView.backgroundColor = KwGaryColor;
        [headView addSubview:lineView];
        
        
        return headView;
    }
    else if (section == 1)
    {
        UIView *headView = [UIView new];
        headView.backgroundColor = [UIColor whiteColor];
        UILabel *lab = [UILabel new];
        lab.text = @"活动详情";
        lab.textColor = [UIColor blackColor];
        lab.font = KwFont(15);
        [headView addSubview:lab];
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(headView.mas_left).offset(20);
            make.top.equalTo(headView.mas_top).offset(15);
            make.height.equalTo(@15);
        }];
        
        UIView *lineView = [UIView new];
        lineView.frame = CGRectMake(0, 46, self.view.bounds.size.width, 1.5);
        lineView.backgroundColor = KwGaryColor;
        [headView addSubview:lineView];
        return headView;
    }
    else
    {
        UIView *headView = [UIView new];
        headView.backgroundColor = KwGaryColor;
        return headView;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *prosecutorCell_ID = @"ProsecutorCell";
    static NSString *doubleLabCell_ID = @"DoubleLabCell";
    static NSString *photoManageCell_ID = @"PhotoManageCell";
    
    if (indexPath.section == 0)
    {
        ProsecutorCell * cell = [tableView dequeueReusableCellWithIdentifier:prosecutorCell_ID];
        if (!cell)
        {
            cell = [[ProsecutorCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:prosecutorCell_ID];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        return cell;
    }
    else if (indexPath.section == 1)
    {
        DoubleLabCell *cell;
        cell = [tableView dequeueReusableCellWithIdentifier:doubleLabCell_ID];
        if (!cell)
        {
            cell = [[DoubleLabCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:doubleLabCell_ID];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        cell.constStr = _constArr[indexPath.row];
        cell.paraStr = _paraArr[indexPath.row];
        return cell;
    }
    else
    {
        PhotoManageCell *cell;
        cell = [tableView dequeueReusableCellWithIdentifier:photoManageCell_ID];
        if (!cell)
        {
            cell = [[PhotoManageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:photoManageCell_ID];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        if (indexPath.section == 2)
        {
            cell.leftTitle = @"活动现场照片管理";
        }
        else
        {
            cell.leftTitle = @"票据照片管理";
        }
        return cell;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
